package com.xxh.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxh.blog.dao.CommentDao;
import com.xxh.blog.entity.Comment;
import com.xxh.blog.entity.vo.CommentVo;
import com.xxh.blog.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CommentServiceImpl extends ServiceImpl<CommentDao, Comment> implements CommentService {

    @Autowired
    CommentDao commentDao;


    @Override
    public IPage<CommentVo> paging(Page page, Integer essayid, Integer uid, String order) {

        QueryWrapper<CommentVo> wrapper = new QueryWrapper<>();
        wrapper.eq(essayid != null, "post_id", essayid)
                .eq(uid != null, "user_id", uid)
                .orderByDesc(order != null, order);
        return commentDao.paging(page, wrapper);
    }
}
